#include <stdio.h>
#include <unistd.h>
#include <getopt.h>

char OPTION_MATRIX_FILE[50];
char OPTION_IN_FILE[50];

static char * VERSION="0.1";

void init(int argc, char* argv[]){
  OPTION_IN_FILE[0]='\0';
  OPTION_MATRIX_FILE[0]='\0';

  int c;
  int helpflg = 0,
      errflg = 0;


  struct option longopts[] =
  {
    {"version", 0, 0, 'v'},
    {"input-stp-file", 1, 0, 'i'},
    {"output-matrix-file", 1, 0, 'm'},
    {"help", 0, 0, 'h'},
    {0, 0, 0, 0}
  };

  while ((c = getopt_long (argc, argv, "i:m:p:vh", longopts, NULL)) != EOF)
  {
    switch(c)
    {
      case 'v':
        printf("version %s\n", VERSION);
        exit(0);
      case 'i':
        sprintf(OPTION_IN_FILE, "%s", optarg);
        break;
      case 'm':
        sprintf(OPTION_MATRIX_FILE, "%s", optarg);
        break;
      case 'h':
	helpflg=1; break;
      case '?':
        errflg++;
        break;
      default:
        break;
    }
  }

  if(helpflg || errflg || OPTION_IN_FILE[0]=='\0')
  {
     fprintf(stderr,"Usage:\n\t pigeon -i <file> [OPTION]\n\n%s%s%s%s",
    "\t-v, --version\t\t     print the version number\n ",
    "\t-i, --input-stp-file         the input stp file\n",
    "\t-m, --output-matrix-file     output the relationship graph of all pis as a matrix in a file\n",
    "\t-h, --help\t\t     print this help\n"
     );
    exit(0);
  }
}
